//
//  SINAStueHomeActivityItemTableViewCell.m
//  sinashebao
//
//  Created by  androidlongs on 2018/1/16.
//  Copyright © 2018年  androidlongs. All rights reserved.
// 学生组队

#import "SINAStueHomeActivityItemTableViewCell.h"
#import "SINACircularBeadUtils.h"
#import "SINAUiviewClickLiserner.h"
#import "SINAStudentHomeActivityItemPop.h"
#import "SINACalendarUtils.h"
#import "SINASINAStuHomeCoursItemModel2.h"
#import "SINAStuActivityTargetModel.h"
#import "SINAStuActivityImpressModel.h"

//UIGestureRecognizerDelegate
@interface SINAStueHomeActivityItemTableViewCell()
//时间轴时间
@property (weak, nonatomic) IBOutlet UIImageView *itemTimeIconImageView;
@property (weak, nonatomic) IBOutlet UILabel *itemTimeLabel;
@property (weak, nonatomic) IBOutlet UIView *itemItemUpDiviView;

@property (weak, nonatomic) IBOutlet UIView *itemItemNextDiviView;


//阴影层
@property (weak, nonatomic) IBOutlet UIView *itemView1;
@property (weak, nonatomic) IBOutlet UIView *itemView11;
@property (weak, nonatomic) IBOutlet UIImageView *itemView1TimeIconImageView;
@property (weak, nonatomic) IBOutlet UIImageView *itemView1LocationIconImageView;
@property (weak, nonatomic) IBOutlet UIView *itemView1StartView;
@property (weak, nonatomic) IBOutlet UIImageView *itemView1StartIconImageView;




@property (weak, nonatomic) IBOutlet UIView *itemView12;
@property (weak, nonatomic) IBOutlet UIView *itemViewDeleteView;
@property (weak, nonatomic) IBOutlet UILabel *itemDeleteLabel;


//活动标题
@property (weak, nonatomic) IBOutlet UILabel *activityTitleLabel1;
//活动描述
@property (weak, nonatomic) IBOutlet UILabel *activityDesLabel1;
//活动时间
@property (weak, nonatomic) IBOutlet UILabel *activityTimeLabel1;
//活动地点
@property (weak, nonatomic) IBOutlet UILabel *activityLocationLabel1;
@property (weak, nonatomic) IBOutlet UIButton *startButton;

//组队前的头像小图标
@property (weak, nonatomic) IBOutlet UIImageView *activityAddteamImageView;
//组队文字
@property (weak, nonatomic) IBOutlet UILabel *activityTitleLabel;
//想组队的人数
@property (weak, nonatomic) IBOutlet UILabel *activityTeamNumLabel;
//向下的箭头
@property (weak, nonatomic) IBOutlet UIImageView *moreImageView;

//想与你组队的人
@property (weak, nonatomic) IBOutlet UILabel *temePeopleLabel;
//暂无想与你组队的人
@property (weak, nonatomic) IBOutlet UILabel *noTemePeopleLabel;
//想与你组队的人
@property (weak, nonatomic) IBOutlet UIScrollView *temePeopleScrollView;
//发起组队的人
@property (weak, nonatomic) IBOutlet UILabel *otherPeopleLabel;
//暂无发起组队的人
@property (weak, nonatomic) IBOutlet UILabel *noOtherPeopleLabel;

//发起组队的人
@property (weak, nonatomic) IBOutlet UIScrollView *otherPeopleScrollView;
//向上的箭头
@property (weak, nonatomic) IBOutlet UIImageView *activityUpImageView;
//向上箭头的覆盖层
@property (weak, nonatomic) IBOutlet UIView *activityUpUiView;

//左箭头
@property (weak, nonatomic) IBOutlet UIImageView *activityToLeftImageView;
@property (weak, nonatomic) IBOutlet UIView *activityToLeftUIView;
//右箭头
@property (weak, nonatomic) IBOutlet UIImageView *activityToRightImageView;
@property (weak, nonatomic) IBOutlet UIView *activityToRightUIView;

//条目一点击事件
@property (weak, nonatomic) IBOutlet UIView *itemView1ClickView;



//条目4中活动显示标题
@property (weak, nonatomic) IBOutlet UILabel *activityTitleLabel4;
@property (weak, nonatomic) IBOutlet UILabel *activityTameFlagLabel;

//条目4中 消息显示
@property (weak, nonatomic) IBOutlet UIImageView *activityMsgImageView;
//条目4中 消息上层覆盖
@property (weak, nonatomic) IBOutlet UIView *activityMsgUiView;
//条目4中 组队人头像
@property (weak, nonatomic) IBOutlet UIImageView *otherUserImageView;
//条目4中 组队人姓名
@property (weak, nonatomic) IBOutlet UILabel *otherUserNameLabel;
//条目4中 组队模式文字
@property (weak, nonatomic) IBOutlet UILabel *activityFlagLabel4;
//条目4中 组队完成按钮
@property (weak, nonatomic) IBOutlet UIButton *activityFinishButton;
@property (weak, nonatomic) IBOutlet UIView *activityFinishPrentView;
@property (weak, nonatomic) IBOutlet UIImageView *activityStatue4ImageView;

//条目4中显示活动时间
@property (weak, nonatomic) IBOutlet UILabel *activityTimeLabel4;
//条目4中显示活动地址
@property (weak, nonatomic) IBOutlet UILabel *activityLocationLabel4;
//条目4中 组队标识
@property (weak, nonatomic) IBOutlet UIImageView *activityTeamFlagImageview4;
//条目4中 删除布局
@property (weak, nonatomic) IBOutlet UIView *activityDeleteUiview4;
//条目4中 删除文字
@property (weak, nonatomic) IBOutlet UIView *activityDeleteUiLable4;

//条目4中 取消组队 布局
@property (weak, nonatomic) IBOutlet UIView *activityCancleUiview4;
//条目4中 取消组队 文字
@property (weak, nonatomic) IBOutlet UIView *activityCancleUiLable4;


//条目5中 活动标题
@property (weak, nonatomic) IBOutlet UILabel *activityTitleLabel5;
//条目5中 活动时间
@property (weak, nonatomic) IBOutlet UILabel *activityTimeLabel5;
//条目5中 活动地址
@property (weak, nonatomic) IBOutlet UILabel *activityLocationLabel5;
//条目5中  时间位置小图标
@property (weak, nonatomic) IBOutlet UIImageView *activityItem5TimeIconImageView;
@property (weak, nonatomic) IBOutlet UIImageView *activityItem5LocationIconImageView;

//条目5中 活动标识
@property (weak, nonatomic) IBOutlet UIImageView *activityTemeFlagImageView;
@property (weak, nonatomic) IBOutlet UILabel *activityTeamFlag5Label;

//条目5中 向下的箭头
@property (weak, nonatomic) IBOutlet UIImageView *activityNextImageView5;
//条目5中 向下的箭头的覆盖层
@property (weak, nonatomic) IBOutlet UIView *activityNextUiView5;
@property (weak, nonatomic) IBOutlet UIView *activityItem5ClickView;


//条目6中 组队活动标识
@property (weak, nonatomic) IBOutlet UIImageView *activityTemeFlagImageView6;
@property (weak, nonatomic) IBOutlet UILabel *activityTemeFlagLabel6;

//条目6中 活动标题
@property (weak, nonatomic) IBOutlet UILabel *activityTitleLabel6;
//条目6中 活动时间
@property (weak, nonatomic) IBOutlet UILabel *activityTimeLabel6;
//条目6中 活动地址
@property (weak, nonatomic) IBOutlet UILabel *activityLocationLabel6;
//条目6中 组队人头像
@property (weak, nonatomic) IBOutlet UIImageView *otherUserImageView6;
//条目6中 组队人姓名
@property (weak, nonatomic) IBOutlet UILabel *otherUserNameLabel6;
//条目6中 组队模式文字
@property (weak, nonatomic) IBOutlet UILabel *activityFlagLabel6;
//条目6中 评价文字 小目标
@property (weak, nonatomic) IBOutlet UIView *activityPariseLabel6;
@property (weak, nonatomic) IBOutlet UIView *activityItem6ClickView;


@property (weak, nonatomic) IBOutlet UIImageView *activityItem6TimeIconImageView;
@property (weak, nonatomic) IBOutlet UIImageView *activityItem6LocationIconImageView;

//显示图片的位置
@property (weak, nonatomic) IBOutlet UIView *activityPariseImageUiview;
//条目6中 向上显示的箭头
@property (weak, nonatomic) IBOutlet UIImageView *activityPariseToUpImageView;
//条目6中 向上显示箭头的覆盖层
@property (weak, nonatomic) IBOutlet UIView *activityPariseToUpUiview;

//条目7中显示文字
@property (weak, nonatomic) IBOutlet UILabel *addActivityLabel;

@property (weak, nonatomic) IBOutlet UIView *itemView2;
@property (weak, nonatomic) IBOutlet UIView *itemView21;

@property (weak, nonatomic) IBOutlet UIView *itemView3;
@property (weak, nonatomic) IBOutlet UIView *itemView31;

@property (weak, nonatomic) IBOutlet UIView *itemView4;
@property (weak, nonatomic) IBOutlet UIView *itemView41;
@property (weak, nonatomic) IBOutlet UIView *itemView42;

@property (weak, nonatomic) IBOutlet UIView *itemView4ClickVIew;



@property (weak, nonatomic) IBOutlet UIView *itemView5;
@property (weak, nonatomic) IBOutlet UIView *itemView6;
@property (weak, nonatomic) IBOutlet UIView *itemView7;
@property (weak, nonatomic) IBOutlet UIView *itemView71;

@property (weak, nonatomic) IBOutlet UIView *itemView51;


@end
@implementation SINAStueHomeActivityItemTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.otherPeopleScrollView.showsVerticalScrollIndicator=NO;
    self.temePeopleScrollView.showsVerticalScrollIndicator=NO;
    self.otherPeopleScrollView.showsHorizontalScrollIndicator=NO;
    self.temePeopleScrollView.showsHorizontalScrollIndicator = NO;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

-(void)setModel:(SINAStuHomeCoursItemModel *)model{
    _model = model;
    
    
    self.itemView7.hidden=YES;
    self.itemView71.hidden=YES;
    
    //活动描述
    NSString *activeDes = model.activityDes;
    activeDes=@"";
    CGFloat flag=-12.5;
    if (UI_IS_IPHONE6PLUS) {
        flag=-7.5;
    }
    //时间轴相关
    self.itemTimeLabel.frame=CGRectMake(23+flag, 38, CGRectGetWidth(self.frame), 21);
    self.itemTimeIconImageView.frame=CGRectMake(67+flag, 42,10, 10);
    self.itemItemUpDiviView.frame=CGRectMake(72+flag, -1,1, CGRectGetMaxY(self.itemTimeIconImageView.frame)-14);
    self.itemItemNextDiviView.frame=CGRectMake(72+flag, CGRectGetMaxY(self.itemTimeIconImageView.frame)+5,1,52);
    
    DLog(@"currentTime %@",model.itemTime);
    self.itemTimeLabel.text=[SINACalendarUtils getDateStringWithTimeStr:model.itemTime andFormat:@"HH:mm"];
    
    if ([model.activityStatue integerValue]==1) {
        //组队刚刚发出 未开始未组队成功
        self.itemView1.frame = CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, 10, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-30, 92);
        self.itemView11.frame = CGRectMake(0,0, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20, CGRectGetWidth( self.itemView1.frame));
        self.itemView12.frame = CGRectMake(0, 0, CGRectGetWidth(self.itemView1.frame),CGRectGetHeight(self.itemView1.frame));
        
        self.itemViewDeleteView.frame =CGRectMake(0, 0,CGRectGetWidth(self.itemView1.frame),CGRectGetHeight( self.itemView1.frame));
        if (mainW==414) {
            self.itemDeleteLabel.frame = CGRectMake(0,CGRectGetHeight(self.itemViewDeleteView.frame)/2-21/2, CGRectGetWidth(self.itemViewDeleteView.frame)-26, 21);
        }else{
            self.itemDeleteLabel.frame = CGRectMake(0,CGRectGetHeight(self.itemViewDeleteView.frame)/2-21/2, CGRectGetWidth(self.itemViewDeleteView.frame)-25, 21);
        }
        self.itemView1ClickView.frame=CGRectMake(0, 0, CGRectGetWidth(self.itemView1.frame)/3*2, CGRectGetHeight(self.itemView1.frame));
        self.itemView1ClickView.backgroundColor=[UIColor clearColor];
        [SINACircularBeadUtils makeCircularBead:4 andView:self.itemView12 andIsSetBackground:NO];
        [SINAViewShadowUtils updateViewShadow:self.itemView1 andWithShadowWidth:0 andWithShadowHeight:1 andWithShadowColor:[UIColor blackColor]];
        self.activityTitleLabel1.frame=CGRectMake(15, 10, 150, 21);
        
        self.itemView1TimeIconImageView.frame=CGRectMake(15, CGRectGetMaxY(self.activityTitleLabel1.frame)+18, 10, 10);
        self.itemView1LocationIconImageView.frame=CGRectMake(15, CGRectGetMaxY(self.itemView1TimeIconImageView.frame)+10,9, 13);
        
        if (activeDes==nil||[activeDes isEqualToString:@""]) {
            self.activityDesLabel1.hidden=YES;
            self.activityTimeLabel1.frame=CGRectMake(CGRectGetMaxX(self.itemView1TimeIconImageView.frame)+5, CGRectGetMaxY(self.activityTitleLabel1.frame)+12, 150, 21);
        }else{
            self.activityDesLabel1.hidden=NO;
            self.activityDesLabel1.frame=CGRectMake(15, CGRectGetMaxY(self.activityTitleLabel1.frame)+12, 150, 21);
            self.activityTimeLabel1.frame=CGRectMake(CGRectGetMaxX(self.itemView1TimeIconImageView.frame)+15, CGRectGetMaxY(self.activityDesLabel1.frame), CGRectGetWidth(self.activityDesLabel1.frame)-30, 21);
        }
        self.activityLocationLabel1.frame=CGRectMake(CGRectGetMaxX(self.itemView1LocationIconImageView.frame)+5, CGRectGetMaxY(self.activityTimeLabel1.frame), CGRectGetWidth(self.activityTimeLabel1.frame)-10, 21);
        
        self.itemView1StartView.frame=CGRectMake(CGRectGetWidth(self.itemView1.frame)-64, CGRectGetHeight(self.itemView1.frame)/2-20, 50, 62);
        self.itemView1StartIconImageView.frame = CGRectMake(CGRectGetWidth(self.itemView1StartView.frame)/2-34/2, 0, 34, 34);
        
        self.startButton.frame=CGRectMake(0,CGRectGetMaxY(self.itemView1StartIconImageView.frame), CGRectGetWidth(self.itemView1StartView.frame), 22);
        
        //活动未开始清除颜色
        self.itemView1StartView.backgroundColor=[UIColor clearColor];
        [self.startButton setBackgroundColor:[UIColor clearColor]];
        [self.startButton setTitleColor:[UIColor colorWithHexString:@"#212121"] forState:UIControlStateNormal];
        WeakSelf;
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.itemView1ClickView andWithBlick:^(UIView *view) {
            if (weakSelf.itemViewDeleteView .hidden) {
                DLog(@"点击查看详情");
                if (weakSelf.activityDesItemBlock) {
                    weakSelf.activityDesItemBlock(weakSelf.position,3,model);
                }
            } else {
                [UIView animateWithDuration:0.65 animations:^{
                    weakSelf.itemView11.frame = CGRectMake(0, 0, mainW-CGRectGetMaxX(weakSelf.itemTimeIconImageView.frame)-20, 135);
                } completion:^(BOOL finished) {
                    weakSelf.itemViewDeleteView .hidden=YES;
                }];
            }
        }];
        
        
        //设置完成按钮
        NSInteger activityStartTime = [self.model.activityStartTime integerValue];
        NSInteger activityEndTime = [self.model.activityStopTime integerValue];
        //当前时间
        NSInteger currentTime = [[SINACalendarUtils currentTimeStr] integerValue];
        
        if (currentTime<activityStartTime) {
            DLog(@"活动未开始");
            //home_sign_no_start_icon
            self.itemView1StartIconImageView.image=[UIImage imageNamed:@"home_sign_no_start_icon"];
            //活动未开始
            [self.startButton setTitleColor:[UIColor colorWithHexString:@"#878787"] forState:UIControlStateNormal];
            //活动未开始
            [self.startButton setTitle:@"未开始" forState:UIControlStateNormal];
        }else if(currentTime>=activityStartTime&&currentTime<=(activityEndTime)){
            //中
            //activity_finish_icon
            self.itemView1StartIconImageView.image=[UIImage imageNamed:@"activity_finish_icon"];
            DLog(@"活动中");
            [self.startButton setTitleColor:[UIColor colorWithHexString:@"#4F8FD7"] forState:UIControlStateNormal];
            [self.startButton setTitle:@"活动中" forState:UIControlStateNormal];
        }else if(currentTime>=activityEndTime&&currentTime<=(activityEndTime+30*60*1000)){
            //活动结束 以及结束后的半小时
            self.itemView1StartIconImageView.image=[UIImage imageNamed:@"activity_finish_icon"];
            DLog(@"完成");
            [self.startButton setTitle:@"完成" forState:UIControlStateNormal];
        }else{
            //超时
            [self.startButton setTitle:@"超时" forState:UIControlStateNormal];
            DLog(@"超时 未完成");
            self.itemView1StartIconImageView.image=[UIImage imageNamed:@"activity_no_finish_icon"];
        }
        
        
        [SINACircularBeadUtils makeCircularBead:1 andView:self.startButton andIsSetBackground:NO];
        
        if (model.activityShowDetaile) {
            [self showActivityDeatile:model];
        } else {
            self.itemView2.hidden=NO;
            self.itemView21.hidden = NO;
            self.itemView3.hidden=YES;
            self.itemView2.frame=CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, CGRectGetMaxY(self.itemView1.frame)+6, CGRectGetWidth(self.itemView1.frame), 42);
            self.itemView21.frame=CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, CGRectGetMaxY(self.itemView1.frame)+6, CGRectGetWidth(self.itemView1.frame), 42);
            
            [SINACircularBeadUtils makeCircularBead:4 andView:self.itemView2 andIsSetBackground:NO];
            
            [SINAViewShadowUtils updateViewShadow:self.itemView21 andWithShadowWidth:0 andWithShadowHeight:2 andWithShadowColor:[UIColor blackColor] andWithShadowRadius:3];
            self.itemView1.layer.zPosition=3;
            self.itemView2.layer.zPosition=2;
            self.itemView21.layer.zPosition=1;
            self.activityAddteamImageView.frame=CGRectMake(14, CGRectGetHeight(self.itemView2.frame)/2-7, 12, 14);
            self.activityTitleLabel.frame=CGRectMake(CGRectGetMaxX(self.activityAddteamImageView.frame)+10, CGRectGetHeight(self.itemView2.frame)/2-10, 35, 21);
            self.activityTeamNumLabel.frame=CGRectMake(CGRectGetMaxX(self.activityTitleLabel.frame)+5, CGRectGetHeight(self.itemView2.frame)/2-10, 140, 21);
            self.moreImageView.frame=CGRectMake(CGRectGetWidth(self.itemView2.frame)-13-10, CGRectGetHeight(self.itemView2.frame)/2-4, 15, 7);
            
            self.itemItemNextDiviView.frame=CGRectMake(72+flag, CGRectGetMaxY(self.itemTimeIconImageView.frame)+5,1,CGRectGetHeight(self.itemView1.frame)/2+CGRectGetHeight(self.itemView2.frame)+15);
            
            if (currentTime>(activityEndTime)) {
                DLog(@"活动超时");
                //活动时间到达结束时不显示与你组队的人
                //活动超时 隐藏iteemView2
                self.itemView2.hidden = YES;
                self.itemView21.hidden = YES;
            }else{
                self.itemView2.hidden = NO;
                self.itemView21.hidden = NO;
            }
            
            __weak typeof(self) weakSelf = self;
            [[SINAUiviewClickLiserner alloc]viewClickFunction:self.itemView21 andWithBlick:^(UIView *view) {
                if (weakSelf.itemCellBlock) {
                    model.activityShowDetaile=YES;
                    weakSelf.itemCellBlock(weakSelf.position, YES, model);
                    [weakSelf showActivityDeatile:model];
                }
            }];
            
            
            //活动未组队 左滑删除
            
            UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(itemView4HandleSwipeFrom:)];
            //设置属性，swipe也是有两种属性设置手指个数及轻扫方向
            swipe.numberOfTouchesRequired = 1;
            //设置轻扫方向(默认是从左往右)
            //direction是一个枚举值有四个选项，我们可以设置从左往右，从右往左，从下往上以及从上往下
            //设置轻扫方向(默认是从左往右)
            [swipe setDirection:(UISwipeGestureRecognizerDirectionLeft)];
            [self.itemView1 addGestureRecognizer:swipe];
            UISwipeGestureRecognizer *swipe2 = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(itemView4HandleSwipeFrom:)];
            //设置属性，swipe也是有两种属性设置手指个数及轻扫方向
            swipe2.numberOfTouchesRequired = 1;
            //设置轻扫方向(默认是从左往右)
            //direction是一个枚举值有四个选项，我们可以设置从左往右，从右往左，从下往上以及从上往下
            //设置轻扫方向(默认是从左往右)
            [swipe2 setDirection:(UISwipeGestureRecognizerDirectionRight)];
            [self.itemView1 addGestureRecognizer:swipe2];
            
            //删除相关
            [[SINAUiviewClickLiserner alloc]viewClickFunction:self.itemViewDeleteView andWithBlick:^(UIView *view) {
                
                [UIView animateWithDuration:0.65 animations:^{
                    weakSelf.itemView11.frame = CGRectMake(0, 0, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20, 135);
                } completion:^(BOOL finished) {
                    if (weakSelf.itemDeleteBlock) {
                        weakSelf.itemDeleteBlock(weakSelf.position, YES, model);
                    }
                }];
            }];
            
        }
        self.itemView4.hidden=YES;
        self.itemView5.hidden=YES;
        self.itemView51.hidden=YES;
        self.itemView6.hidden=YES;
        
        self.activityTitleLabel1.text=model.activityTitle;
        
        self.activityTimeLabel1.text=[NSString stringWithFormat:@"%@-%@",[SINACalendarUtils getDateStringWithTimeStr:model.activityStartTime andFormat:@"HH:mm"],[SINACalendarUtils getDateStringWithTimeStr:model.activityStopTime andFormat:@"HH:mm"]];
        
        self.activityLocationLabel1.text = model.activityLocation;
        
        self.itemTimeLabel.text = [NSString stringWithFormat:@"%@",[SINACalendarUtils getDateStringWithTimeStr:model.activityStartTime andFormat:@"HH:mm"]];
        
        if (model.teamUserList!=nil&&model.teamUserList.count>0) {
            self.activityTeamNumLabel.text=[NSString stringWithFormat:@"有%ld个人想和你组队",(long)model.teamUserList.count];
        } else {
            self.activityTeamNumLabel.text=@"暂无想和你组队的人";
        }
        
        
    }else if ([model.activityStatue integerValue]==2) {
        
        //组队成功
        self.itemView4.hidden=NO;
        self.itemView1.hidden=YES;
        self.itemView2.hidden=YES;
        self.itemView3.hidden=YES;
        self.itemView5.hidden=YES;
        self.itemView51.hidden=YES;
        self.itemView6.hidden=YES;
        self.itemView4.frame = CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, 10, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20-10, 135);
        self.itemView41.frame = CGRectMake(0, 0, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20, 135);
        self.itemView42.frame = CGRectMake(0, 0, CGRectGetWidth(self.itemView4.frame), CGRectGetHeight(self.itemView4.frame));
        self.itemView4ClickVIew.frame = CGRectMake(0, 40, 170, 95);
        self.itemItemNextDiviView.frame=CGRectMake(self.itemItemNextDiviView.frame.origin.x, CGRectGetMaxY(self.itemTimeIconImageView.frame)+5,1,52+42+10);
        [SINACircularBeadUtils makeCircularBead:4 andView:self.itemView42 andIsSetBackground:NO];
        [SINAViewShadowUtils updateViewShadow:self.itemView4 andWithShadowWidth:0 andWithShadowHeight:2 andWithShadowColor:[UIColor blackColor] andWithShadowRadius:3];
        
        //删除相关
        self.activityDeleteUiview4.hidden=YES;
        self.activityDeleteUiview4.frame=CGRectMake(CGRectGetWidth(self.itemView4.frame)-90,0 ,90 , 135);
        self.activityDeleteUiLable4.frame=CGRectMake(CGRectGetWidth(self.activityDeleteUiview4.frame)/2-30,135/2-21/2,60 , 21);
        __weak typeof(self) weakSelf = self;
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityDeleteUiview4 andWithBlick:^(UIView *view) {
            if (!self.activityDeleteUiview4.hidden) {
                [UIView animateWithDuration:0.65 animations:^{
                    weakSelf.itemView41.frame = CGRectMake(0, 0, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20, 135);
                } completion:^(BOOL finished) {
                    self.activityCancleUiview4.hidden=YES;
                    self.activityDeleteUiview4.hidden=YES;
                    if (weakSelf.itemDeleteBlock) {
                        weakSelf.itemDeleteBlock(weakSelf.position, YES, model);
                    }
                }];
            }
            
        }];
        //点击查看详情
        self.itemView4ClickVIew.backgroundColor=[UIColor clearColor];
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.itemView4ClickVIew andWithBlick:^(UIView *view) {
            DLog(@"点击查看详情");
            if (weakSelf.activityDesItemBlock) {
                weakSelf.activityDesItemBlock(weakSelf.position,1,model);
            }
        }];
        
        //点击查看留言详情
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityMsgUiView andWithBlick:^(UIView *view) {
            DLog(@"点击查看详情");
            if (weakSelf.activityDesItemBlock) {
                weakSelf.activityDesItemBlock(weakSelf.position,2,model);
            }
        }];
        //取消相关
        self.activityCancleUiview4.hidden=YES;
        self.activityCancleUiview4.frame=CGRectMake(CGRectGetWidth(self.itemView4.frame)-180,0 ,90 , 135);
        self.activityCancleUiLable4.frame=CGRectMake(CGRectGetWidth(self.activityCancleUiview4.frame)/2-40,135/2-21/2,80 , 21);
        
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityCancleUiview4 andWithBlick:^(UIView *view) {
            if (!self.activityCancleUiview4.hidden) {
                [UIView animateWithDuration:0.65 animations:^{
                    weakSelf.itemView41.frame = CGRectMake(0, 0, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20, 135);
                } completion:^(BOOL finished) {
                    self.activityCancleUiview4.hidden=YES;
                    self.activityDeleteUiview4.hidden=YES;
                    if (weakSelf.itemCancleBlock) {
                        weakSelf.itemCancleBlock(weakSelf.position, YES, model);
                    }
                }];
            }
        }];
        
        self.activityDeleteUiview4.layer.zPosition=1;
        self.activityCancleUiview4.layer.zPosition=1;
        self.itemView41.layer.zPosition=2;
        
        
        //        UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(itemView4HandleSwipeFrom:)];
        //        recognizer.delegate = self;
        //        [self.itemView41 addGestureRecognizer:recognizer];
        
        UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(itemView4HandleSwipeFrom:)];
        //设置属性，swipe也是有两种属性设置手指个数及轻扫方向
        swipe.numberOfTouchesRequired = 1;
        //设置轻扫方向(默认是从左往右)
        //direction是一个枚举值有四个选项，我们可以设置从左往右，从右往左，从下往上以及从上往下
        //设置轻扫方向(默认是从左往右)
        [swipe setDirection:(UISwipeGestureRecognizerDirectionLeft)];
        [self.itemView4 addGestureRecognizer:swipe];
        UISwipeGestureRecognizer *swipe2 = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(itemView4HandleSwipeFrom:)];
        //设置属性，swipe也是有两种属性设置手指个数及轻扫方向
        swipe2.numberOfTouchesRequired = 1;
        //设置轻扫方向(默认是从左往右)
        //direction是一个枚举值有四个选项，我们可以设置从左往右，从右往左，从下往上以及从上往下
        //设置轻扫方向(默认是从左往右)
        [swipe2 setDirection:(UISwipeGestureRecognizerDirectionRight)];
        [self.itemView4 addGestureRecognizer:swipe2];
        
        //活动标题  动态计算
        self.activityTitleLabel4.frame = CGRectMake(15, 10, 40, 21);
        self.activityMsgUiView.frame=CGRectMake(CGRectGetMaxX(self.activityTitleLabel4.frame)+10, 0, 150, 30);
        self.activityMsgImageView.frame=CGRectMake(0, 12, 18, 17);
        
        self.otherUserImageView.frame=CGRectMake(15, CGRectGetMaxY(self.activityTitleLabel4.frame)+10, 40, 40);
        [SINACircularBeadUtils makeCircularView:self.otherUserImageView];
        
        self.otherUserNameLabel.frame=CGRectMake(CGRectGetMaxX(self.otherUserImageView.frame)+10, CGRectGetMaxY(self.activityTitleLabel4.frame)+12, 150, 21);
        self.activityFlagLabel4.frame=CGRectMake(CGRectGetMaxX(self.otherUserImageView.frame)+10, CGRectGetMaxY(self.otherUserNameLabel.frame), 150, 21);
        
        self.activityTimeLabel4.frame=CGRectMake(15, CGRectGetMaxY(self.otherUserImageView.frame)+10, 250, 20);
        self.activityLocationLabel4.frame=CGRectMake(15, CGRectGetMaxY(self.activityTimeLabel4.frame)-4, 250, 21);
        
        
        self.activityFinishPrentView.frame=CGRectMake(CGRectGetWidth(self.itemView4.frame)-68,30, 58, CGRectGetHeight(self.itemView4.frame)-40);
        self.activityStatue4ImageView.frame=CGRectMake(CGRectGetWidth(self.activityFinishPrentView.frame)/2-17, 20, 34, 34);
        
        self.activityFinishButton.frame=CGRectMake(0, CGRectGetMaxY(self.activityStatue4ImageView.frame)+8, CGRectGetWidth(self.activityFinishPrentView.frame), 22);
        
        
        [SINACircularBeadUtils makeCircularBead:4 andView:self.activityFinishButton andIsSetBackgroundColor:[UIColor colorWithHexString:@"FD8D1F"]];
        
        self.activityTeamFlagImageview4.frame=CGRectMake(CGRectGetWidth(self.itemView4.frame)-48, 12, 48, 16);
        self.activityTameFlagLabel .frame=CGRectMake(CGRectGetWidth(self.itemView4.frame)-40, 12, 40, 16);
        
        self.activityTitleLabel4.text = model.activityTitle;
        self.activityTimeLabel4.text=[NSString stringWithFormat:@"%@-%@",[SINACalendarUtils getDateStringWithTimeStr:model.activityStartTime andFormat:@"HH:mm"],[SINACalendarUtils getDateStringWithTimeStr:model.activityStopTime andFormat:@"HH:mm"]];
        
        self.activityLocationLabel4.text = model.activityLocation;
        
        self.itemTimeLabel.text = [NSString stringWithFormat:@"%@",[SINACalendarUtils getDateStringWithTimeStr:model.activityStartTime andFormat:@"HH:mm"]];
        
        
        [self.otherUserImageView sd_setImageWithURL:[NSURL URLWithString:model.activityUserImg] placeholderImage:[UIImage imageNamed:@"默认头像"]];
        self.otherUserNameLabel.text = model.activityUserName;
        
        
        
        NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:16],};
        
        NSString *str =self.model.activityTitle;
        CGSize textSize = [str boundingRectWithSize:CGSizeMake(mainW, 21) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;;
        
        
        
        if (textSize.width>mainW/3*2) {
            textSize.width = mainW/3*2;
        }
        self.activityTitleLabel4.frame=CGRectMake(self.activityTitleLabel4.frame.origin.x, self.activityTitleLabel4.frame.origin.y, textSize.width, 21);
        self.activityMsgUiView.frame=CGRectMake(CGRectGetMaxX(self.activityTitleLabel4.frame)+10, self.activityMsgUiView.frame.origin.y, self.activityMsgUiView.frame.size.width, self.activityMsgUiView.frame.size.height);
        
        
        //按钮设置
        
        //设置完成按钮
        NSInteger activityStartTime = [self.model.activityStartTime integerValue];
        NSInteger activityEndTime = [self.model.activityStopTime integerValue];
        //当前时间
        NSInteger currentTime = [[SINACalendarUtils currentTimeStr] integerValue];
        [self.activityFinishButton setBackgroundColor:[UIColor clearColor]];
        [self.activityFinishPrentView setBackgroundColor:[UIColor clearColor]];
        [self.activityFinishButton setTitleColor:[UIColor colorWithHexString:@"#727272"] forState:UIControlStateNormal];
        if (currentTime<activityStartTime) {
            DLog(@"活动未开始");
            self.activityStatue4ImageView.image=[UIImage imageNamed:@"home_sign_no_start_icon"];
            //活动未开始
            [self.activityFinishButton setTitle:@"完成" forState:UIControlStateNormal];
        }else if(currentTime>=activityStartTime&&currentTime<=(activityEndTime)){
            //中
            DLog(@"活动中");
            self.activityStatue4ImageView.image=[UIImage imageNamed:@"activity_finish_icon"];
            [self.activityFinishButton setTitleColor:[UIColor colorWithHexString:@"#4F8FD7"] forState:UIControlStateNormal];
            [self.activityFinishButton setTitle:@"活动中" forState:UIControlStateNormal];
        }else if(currentTime>=activityEndTime&&currentTime<=(activityEndTime+30*60*1000)){
            //活动结束 以及结束后的半小时
            DLog(@"完成");
            self.activityStatue4ImageView.image=[UIImage imageNamed:@"activity_finish_icon"];
            [self.activityFinishButton setTitleColor:[UIColor colorWithHexString:@"#4F8FD7"] forState:UIControlStateNormal];
            [self.activityFinishButton setTitle:@"完成" forState:UIControlStateNormal];
        }else{
            //activity_no_finish_icon
            self.activityStatue4ImageView.image=[UIImage imageNamed:@"activity_no_finish_icon"];
            //超时
            [self.activityFinishButton setTitleColor:[UIColor colorWithHexString:@"#727272"] forState:UIControlStateNormal];
            [self.activityFinishButton setTitle:@"超时" forState:UIControlStateNormal];
            DLog(@"超时");
        }
        
        
    }else if ([model.activityStatue integerValue]==3&&!model.activityShowDetaile) {
        
        //组队成功 组队事务完成
        //活动完成状态
        self.itemView4.hidden=YES;
        self.itemView1.hidden=YES;
        self.itemView2.hidden=YES;
        self.itemView21.hidden = YES;
        
        self.itemView3.hidden=YES;
        self.itemView6.hidden=YES;
        self.itemView5.hidden=NO;
        self.itemView51.hidden=NO;
        
        self.itemView5.frame = CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, 10,mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20-10, 90);
        self.itemView51.frame = CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, 10,mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20-10, 90);
        self.activityItem5ClickView.frame=CGRectMake(0, 0, CGRectGetWidth(self.itemView5.frame)-100, CGRectGetHeight(self.itemView5.frame));
        self.itemItemNextDiviView.frame=CGRectMake(self.itemItemNextDiviView.frame.origin.x, CGRectGetMaxY(self.itemTimeIconImageView.frame)+5,1,52+22);
         [SINAViewShadowUtils updateViewShadow:self.itemView51 andWithShadowWidth:0 andWithShadowHeight:2 andWithShadowColor:[UIColor blackColor] andWithShadowRadius:2];
        
        self.activityTitleLabel5.frame = CGRectMake(15, 10, 140, 21);
        self.activityTimeLabel5.frame=CGRectMake(15+14, CGRectGetMaxY(self.activityTitleLabel5.frame)+10, 250, 20);
        self.activityLocationLabel5.frame=CGRectMake(15+14, CGRectGetMaxY(self.activityTimeLabel5.frame)-1, 250, 21);
        
        
        self.activityItem5TimeIconImageView.frame=CGRectMake(15, CGRectGetMaxY(self.activityTitleLabel5.frame)+14, 10, 10);
        self.activityItem5LocationIconImageView.frame=CGRectMake(15, CGRectGetMaxY(self.activityItem5TimeIconImageView.frame)+10,9, 13);
        
        self.activityNextImageView5.frame=CGRectMake(CGRectGetWidth(self.itemView5.frame)-10-15, CGRectGetMaxY(self.activityTimeLabel5.frame)+5, 15, 7);
        self.activityNextUiView5.frame=CGRectMake(CGRectGetWidth(self.itemView5.frame)-120, CGRectGetMaxY(self.activityTimeLabel5.frame), 120, 30);
        self.activityNextUiView5.backgroundColor=[UIColor clearColor];
        __weak typeof(self) weakSelf = self;
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityNextUiView5 andWithBlick:^(UIView *view) {
            model.activityShowDetaile=YES;
            [weakSelf showFinishActivityDeatile:model flag:YES];
        }];
        
        self.activityTemeFlagImageView.frame=CGRectMake(CGRectGetWidth(self.itemView5.frame)-43, 12, 46, 15);
        self.activityTeamFlag5Label.frame=CGRectMake(CGRectGetWidth(self.itemView5.frame)-29, 12, 36, 15);
        
        self.activityTitleLabel5.text = model.activityTitle;
        self.activityTimeLabel5.text=[NSString stringWithFormat:@"%@-%@",[SINACalendarUtils getDateStringWithTimeStr:model.activityStartTime andFormat:@"HH:mm"],[SINACalendarUtils getDateStringWithTimeStr:model.activityStopTime andFormat:@"HH:mm"]];
        
        self.activityLocationLabel5.text = model.activityLocation;
        
        self.itemTimeLabel.text = [NSString stringWithFormat:@"%@",[SINACalendarUtils getDateStringWithTimeStr:model.activityStartTime andFormat:@"HH:mm"]];
        
        
        [self.otherUserImageView sd_setImageWithURL:[NSURL URLWithString:model.activityUserImg] placeholderImage:[UIImage imageNamed:@"默认头像"]];
        self.otherUserNameLabel.text = model.activityUserName;
        
        self.activityItem5ClickView.backgroundColor=[UIColor clearColor];
        
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityItem5ClickView andWithBlick:^(UIView *view) {
            DLog(@"点击查看详情");
            if (weakSelf.activityDesItemBlock) {
                weakSelf.activityDesItemBlock(weakSelf.position,3,model);
            }
        }];
        
        
        //计算
        NSString *otherUserUid=model.activityUserUid;
        if (otherUserUid==nil||otherUserUid.length==0||[otherUserUid isEqualToString:@"(null)"]) {
            //未组队模式 不显示队友信息
            self.activityTemeFlagImageView.hidden = YES;
            self.activityTeamFlag5Label.hidden=YES;
        } else {
            //组队模式 显示队友信息
            self.activityTemeFlagImageView.hidden = NO;
            self.activityTeamFlag5Label.hidden=NO;
        }
        
        
        
    }else if ([model.activityStatue integerValue]==3&&model.activityShowDetaile) {
        
        [self showFinishActivityDeatile:model flag:NO];
        
        self.activityTitleLabel6.text = model.activityTitle;
        self.activityTimeLabel6.text=[NSString stringWithFormat:@"%@-%@",[SINACalendarUtils getDateStringWithTimeStr:model.activityStartTime andFormat:@"HH:mm"],[SINACalendarUtils getDateStringWithTimeStr:model.activityStopTime andFormat:@"HH:mm"]];
        
        self.activityLocationLabel6.text = model.activityLocation;
        
        self.itemTimeLabel.text = [NSString stringWithFormat:@"%@",[SINACalendarUtils getDateStringWithTimeStr:model.activityStartTime andFormat:@"HH:mm"]];
        
        
        [self.otherUserImageView6 sd_setImageWithURL:[NSURL URLWithString:model.activityUserImg] placeholderImage:[UIImage imageNamed:@"默认头像"]];
        self.otherUserNameLabel6.text = model.activityUserName;
        
        WeakSelf;
        
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityItem6ClickView andWithBlick:^(UIView *view) {
            DLog(@"点击查看详情");
            if (weakSelf.activityDesItemBlock) {
                weakSelf.activityDesItemBlock(weakSelf.position,3,model);
            }
        }];
        
        
        
        
    }else if ([model.activityStatue integerValue]==4) {
        //显示添加
        self.itemView1.hidden = YES;
        self.itemView2.hidden = YES;
        self.itemView21.hidden = YES;
        
        self.itemView3.hidden = YES;
        self.itemView4.hidden = YES;
        self.itemView5.hidden = YES;
        self.itemView51.hidden=YES;
        self.itemView6.hidden = YES;
        self.itemView7.hidden = NO;
        self.itemView71.hidden = NO;
        //mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20
        self.itemView71.frame = CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, 10, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20-10, 90);
        self.itemView7.frame = CGRectMake(0,0, CGRectGetWidth(self.itemView71.frame), CGRectGetHeight(self.itemView71.frame));
        self.addActivityLabel.frame=CGRectMake(0, CGRectGetHeight(self.itemView7.frame)/2-21/2, CGRectGetWidth(self.itemView7.frame), 21);
        self.itemTimeLabel.hidden = NO;
        self.itemTimeLabel.text =model.itemTime;
        [SINACircularBeadUtils makeCircularBead:4 andView:self.itemView7 andIsSetBackground:NO];
        [SINAViewShadowUtils updateViewShadow:self.itemView71 andWithShadowWidth:0 andWithShadowHeight:2 andWithShadowColor:[UIColor blackColor] andWithShadowRadius:3];
        __weak typeof(self) weakSelf = self;
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.itemView7 andWithBlick:^(UIView *view) {
            if (weakSelf.addItemBlock) {
                weakSelf.addItemBlock(0);
            }
        }];
        
        if (self.totalNumber==1) {
            self.itemItemUpDiviView.hidden=YES;
            self.itemItemNextDiviView.hidden=YES;
        }
        
        
        
        
    }
    
    
    if (self.pos==0) {
        self.itemItemUpDiviView.hidden = YES;
    } else {
        self.itemItemUpDiviView.hidden = NO;
    }
    if (self.pos==self.totalNumber-1) {
        self.itemItemNextDiviView.hidden = YES;
    } else {
        self.itemItemNextDiviView.hidden = NO;
    }
    
    
}
#pragma mark-手势代理，解决和tableview点击发生的冲突
//-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
//    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {//判断如果点击的是tableView的cell，就把手势给关闭了
//        return NO;//关闭手势
//    }//否则手势存在
//    return NO;
//}
- (void)itemView4HandleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
    
    
    if (recognizer.view==self.itemView4) {
        
        
        if(recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
            DLog(@"swipe left");
            self.activityDeleteUiview4.hidden=NO;
            self.activityCancleUiview4.hidden=NO;
            [UIView animateWithDuration: 0.65 animations: ^{
                self.itemView41.frame = CGRectMake(-180, 0, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20, 135);
            } completion: nil];
            
        }
        if(recognizer.direction == UISwipeGestureRecognizerDirectionRight) {
            DLog(@"swipe right");
            [UIView animateWithDuration:0.65 animations:^{
                self.itemView41.frame = CGRectMake(0, 0, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20, 135);
            } completion:^(BOOL finished) {
                self.activityCancleUiview4.hidden=YES;
                self.activityDeleteUiview4.hidden=YES;
            }];
            
            
        }
        
    }else if(recognizer.view==self.itemView1){
        //未组队 左滑删除
        if(recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
            DLog(@"swipe left");
            self.itemViewDeleteView .hidden=NO;
            [UIView animateWithDuration: 0.65 animations: ^{
                
                self.itemView11.frame = CGRectMake(-90, 0, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20, 135);
            } completion: nil];
            
        }
        if(recognizer.direction == UISwipeGestureRecognizerDirectionRight) {
            DLog(@"swipe right");
            [UIView animateWithDuration:0.65 animations:^{
                self.itemView11.frame = CGRectMake(0, 0, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20, 135);
            } completion:^(BOOL finished) {
                self.itemViewDeleteView .hidden=YES;
                
            }];
            
            
        }
        
    }
    
    
    
    
    
}
//组队完成 显示详情
- (void)showFinishActivityDeatile:(SINAStuHomeCoursItemModel*)model flag:(BOOL)flag{
    
    DLog(@"组队活动完成 显示详情");
    //组队成功 组队事务完成 显示详情
    //活动完成
    //分两种情况 一是未组队的活动 显示页面
    // 二是组队成功的 显示 页面
    self.itemView4.hidden=YES;
    self.itemView1.hidden=YES;
    self.itemView2.hidden=YES;
    self.itemView21.hidden = YES;
    
    self.itemView3.hidden=YES;
    self.itemView5.hidden=YES;
    self.itemView51.hidden=YES;
    self.itemView6.hidden=NO;
    
    self.itemView6.frame = CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, 10, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20-10, 350);
    self.activityItem6ClickView.frame=CGRectMake(0, 0, CGRectGetWidth(self.itemView6.frame)-100, CGRectGetHeight(self.itemView6.frame)/3);
    self.itemItemNextDiviView.frame=CGRectMake(self.itemItemNextDiviView.frame.origin.x, CGRectGetMaxY(self.itemTimeIconImageView.frame)+5,1,52+400);
    [SINACircularBeadUtils makeCircularBead:4 andView:self.itemView6 andIsSetBackground:NO];
    
    
    self.activityTemeFlagImageView6.frame=CGRectMake(CGRectGetWidth(self.itemView6.frame)-43, 12, 46, 15);
    self.activityTemeFlagLabel6.frame=CGRectMake(CGRectGetWidth(self.itemView6.frame)-35, 12, 36, 15);
    
    
    self.activityTitleLabel6.frame = CGRectMake(15, 10, 140, 21);
    self.otherUserImageView6.frame=CGRectMake(15, CGRectGetMaxY(self.activityTitleLabel6.frame)+10, 40, 40);
    [SINACircularBeadUtils makeCircularView:self.otherUserImageView6];
    
    self.otherUserNameLabel6.frame=CGRectMake(CGRectGetMaxX(self.otherUserImageView6.frame)+10, CGRectGetMaxY(self.activityTitleLabel6.frame)+10, 150, 21);
    self.activityFlagLabel6.frame=CGRectMake(CGRectGetMaxX(self.otherUserImageView6.frame)+10, CGRectGetMaxY(self.otherUserNameLabel6.frame), 150, 21);
    
    //小目标开始显示的Y轴坐标
    NSInteger tagetY =CGRectGetMaxY(self.otherUserImageView6.frame)+10;
    
    //计算
    NSString *otherUserUid=model.activityUserUid;
    if (otherUserUid==nil||otherUserUid.length==0||[otherUserUid isEqualToString:@"(null)"]) {
        //未组队模式 不显示队友信息
        self.activityTemeFlagImageView6.hidden = YES;
        self.activityTemeFlagLabel6.hidden = YES;
        self.otherUserImageView6.hidden=YES;
        self.otherUserNameLabel6.hidden=YES;
        self.activityFlagLabel6.hidden=YES;
        tagetY =CGRectGetMaxY(self.activityTitleLabel6.frame)+10;
    } else {
        //组队模式 显示队友信息
        self.activityTemeFlagImageView6.hidden = NO;
        self.activityTemeFlagLabel6.hidden = NO;
        self.otherUserImageView6.hidden=NO;
        self.otherUserNameLabel6.hidden=NO;
        self.activityFlagLabel6.hidden=NO;
        tagetY =CGRectGetMaxY(self.otherUserImageView6.frame);
    }
    
    self.activityPariseLabel6.frame=CGRectMake(15, CGRectGetMaxY(self.otherUserImageView6.frame)+10, CGRectGetWidth(self.itemView6.frame)-30, 21);
    self.activityPariseImageUiview.frame=CGRectMake(15, CGRectGetMaxY(self.activityPariseLabel6.frame)+10, CGRectGetWidth(self.itemView6.frame)-30, 189);
    
    
    
    
    
    
    // 小目标
    //    NSString *activityDes = model.activityDes;
    NSMutableArray *targetArray = model.teamTargetArray;
    if (targetArray==nil||targetArray.count==0) {
        self.activityPariseLabel6.frame=CGRectMake(15,tagetY, CGRectGetWidth(self.itemView6.frame)-30, 0);
    } else {
        self.activityPariseLabel6.frame=CGRectMake(15, tagetY, CGRectGetWidth(self.itemView6.frame)-30,targetArray.count*21);
        for (NSInteger i=0; i<targetArray.count; i++) {
            SINAStuActivityTargetModel *targetModel =targetArray[i];
            UILabel *itemLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 21*i, CGRectGetWidth(self.activityPariseLabel6.frame), 21)];
            itemLabel.text = [NSString stringWithFormat:@"%ld. %@",(i+1),targetModel.title];
            itemLabel.font=[UIFont systemFontOfSize:14];
            itemLabel.textColor=[UIColor colorWithHexString:@"#565656"];
            [self.activityPariseLabel6 addSubview:itemLabel];
        }
    }
    //随笔
    NSMutableArray *impressArray = model.teamImpressionArray;
    if (impressArray!=nil&&impressArray.count>0) {
        SINAStuActivityImpressModel *impressModel = impressArray[0];
        //随笔 内容
        NSString *impressContent = impressModel.impressDes;
        //测量
        UILabel *taretLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(self.activityPariseLabel6.frame), CGRectGetWidth(self.activityPariseLabel6.frame), 21)];
        taretLabel.text=[NSString stringWithFormat:@"%@",impressContent];
        taretLabel.font=[UIFont systemFontOfSize:14];
        taretLabel.numberOfLines=0;
        taretLabel.textColor=[UIColor colorWithHexString:@"#676767"];
        // 设置文字属性 要和label的一致
        NSDictionary *attrs = @{NSFontAttributeName : taretLabel.font};
        CGSize maxSize = CGSizeMake(CGRectGetWidth(self.activityPariseLabel6.frame), MAXFLOAT);
        // 计算文字占据的高度
        CGSize size = [impressModel.impressDes boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
        // 设置label尺寸
        taretLabel.frame = CGRectMake(0,CGRectGetHeight(self.activityPariseLabel6.frame)+10, CGRectGetWidth(self.activityPariseLabel6.frame), size.height);
        [self.activityPariseLabel6 addSubview:taretLabel];
        CGRect preFrame=self.activityPariseLabel6.frame;
        CGRect currentFrame = CGRectMake(preFrame.origin.x, preFrame.origin.y,preFrame.size.width, preFrame.size.height+CGRectGetHeight(taretLabel.frame)+10);
        self.activityPariseLabel6.frame = currentFrame;
    }
    
    
    NSMutableArray *temaImageArray = [[NSMutableArray alloc]init];
    if (impressArray!=nil&&impressArray.count>0) {
        SINAStuActivityImpressModel *impressModel = impressArray[0];
        temaImageArray =impressModel.temaImageArray;
    }
    
    //每行列数
    NSInteger rank = 3;
    //每列间距
    CGFloat rankMargin = 10;
    //每行间距
    CGFloat rowMargin = 10;
    //Item索引 ->根据需求改变索引
    NSUInteger index = 0;
    if (temaImageArray==nil) {
        index=0;
    } else if(temaImageArray.count>6){
        index = 6;
    }else {
        index = temaImageArray.count;
    }
    
    //每个Item宽高
    CGFloat W = (CGRectGetWidth(self.activityPariseImageUiview.frame)-(rank-1)*rankMargin)/rank;
    CGFloat H = W;
    
    
    if (temaImageArray==nil||temaImageArray.count==0) {
        self.activityPariseImageUiview.hidden=YES;
        self.activityPariseImageUiview.frame=CGRectMake(15, CGRectGetMaxY(self.activityPariseLabel6.frame)-10, CGRectGetWidth(self.itemView6.frame)-30, 0);
    } else if(temaImageArray.count<=3){
        self.activityPariseImageUiview.hidden=NO;
        self.activityPariseImageUiview.frame=CGRectMake(15, CGRectGetMaxY(self.activityPariseLabel6.frame)+10, CGRectGetWidth(self.itemView6.frame)-30, H);
    }else{
        self.activityPariseImageUiview.hidden=NO;
        self.activityPariseImageUiview.frame=CGRectMake(15, CGRectGetMaxY(self.activityPariseLabel6.frame)+10, CGRectGetWidth(self.itemView6.frame)-30, H*2+rowMargin);
    }
    self.activityTimeLabel6.frame=CGRectMake(15+15, CGRectGetMaxY(self.activityPariseImageUiview.frame)+10, CGRectGetWidth(self.itemView6.frame)-30, 21);
    self.activityLocationLabel6.frame=CGRectMake(15+15, CGRectGetMaxY(self.activityTimeLabel6.frame), CGRectGetWidth(self.itemView6.frame)-30, 21);
    self.activityPariseToUpImageView.frame=CGRectMake(CGRectGetWidth(self.itemView6.frame)-30, CGRectGetMaxY(self.activityTimeLabel6.frame)+4, 15, 7);
    self.activityPariseToUpUiview.frame=CGRectMake(CGRectGetWidth(self.itemView6.frame)-120, CGRectGetMaxY(self.activityTimeLabel6.frame), 120, 30);
    
    self.activityItem6TimeIconImageView.frame=CGRectMake(15,CGRectGetMaxY(self.activityPariseImageUiview.frame)+16, 10, 10);
    self.activityItem6LocationIconImageView.frame=CGRectMake(15, CGRectGetMaxY(self.activityItem6TimeIconImageView.frame)+10,9, 13);
    
    
    self.itemView6.frame = CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, 10, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-30, CGRectGetMaxY(self.activityLocationLabel6.frame)+15);
    self.itemItemNextDiviView.frame=CGRectMake(self.itemItemNextDiviView.frame.origin.x, CGRectGetMaxY(self.itemTimeIconImageView.frame)+5,1,CGRectGetMaxY(self.activityLocationLabel6.frame)-20);
    self.activityPariseToUpImageView.transform = CGAffineTransformMakeRotation(180 *M_PI / 180.0);
    
    self.activityPariseImageUiview.backgroundColor=[UIColor clearColor];
    self.activityPariseToUpUiview.backgroundColor=[UIColor clearColor];
    self.activityItem6ClickView.backgroundColor=[UIColor clearColor];
    self.activityPariseLabel6.backgroundColor=[UIColor clearColor];
    //点击收回
    __weak typeof(self) weakSelf = self;
    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityPariseToUpUiview andWithBlick:^(UIView *view) {
        if (weakSelf.itemCellBlock) {
            model.activityShowDetaile=NO;
            weakSelf.itemCellBlock(weakSelf.position, NO, model);
        }
    }];
    
    for (int i = 0 ; i< index; i++) {
        NSString *imageUrl =temaImageArray[i];
        DLog(@"随笔图片 %@",imageUrl);
        //Item X轴
        CGFloat X = (i % rank) * (W + rankMargin);
        //Item Y轴
        NSUInteger Y = (i / rank) * (H +rowMargin);
        //Item top
        CGFloat top = 0;
        UIView *speedView = [[UIView alloc] init];
        speedView.backgroundColor = [UIColor clearColor];
        speedView.frame = CGRectMake(X, Y+top, W, H);
        
        UIImageView *imageView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, W, H)];
        imageView.backgroundColor=[UIColor colorWithHexString:@"#eeeeee"];
        [speedView addSubview:imageView];
        
        //[SINACircularBeadUtils makeCircularView:imageView];
        
        [self.activityPariseImageUiview addSubview:speedView];
        [imageView sd_setImageWithURL:[NSURL URLWithString:imageUrl]];
    }
    
    if (flag) {
        if (self.itemCellBlock) {
            model.itemHeight = CGRectGetHeight(self.itemView6.frame)+10;
            self.itemCellBlock(weakSelf.position, YES, model);
            
        }
    }
    
    
    
    
}

-(void) showActivityDeatile:(SINAStuHomeCoursItemModel*) model{
    self.itemView2.hidden=YES;
    self.itemView21.hidden = YES;
    self.itemView3.hidden=NO;
    NSInteger flag = 215;
    if (UI_IS_IPHONE6PLUS) {
        flag=flag+20;
    }
    self.itemView3.frame=CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, CGRectGetMaxY(self.itemView1.frame)+15, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20-10, flag);
    self.itemView31.frame=CGRectMake(0,0, CGRectGetWidth(self.itemView3.frame),CGRectGetHeight(self.itemView3.frame));
    
    [SINACircularBeadUtils makeCircularBead:4 andView:self.itemView31 andIsSetBackground:NO];
    [SINAViewShadowUtils updateViewShadow:self.itemView3 andWithShadowWidth:0 andWithShadowHeight:2 andWithShadowColor:[UIColor blackColor] andWithShadowRadius:2];
    self.itemItemNextDiviView.frame=CGRectMake(self.itemItemNextDiviView.frame.origin.x, CGRectGetMaxY(self.itemTimeIconImageView.frame)+5,1,52+214+10);
    
    
    if([UIScreen mainScreen].bounds.size.height == 667){
        //3 判断是否为4.7inch   375*667   750*1334   iphone8
        self.itemItemNextDiviView.frame=CGRectMake(self.itemItemNextDiviView.frame.origin.x, CGRectGetMaxY(self.itemTimeIconImageView.frame)+5,1,52+214+12);
    }else{
        //4 判断是否为5.5inch   414*1104   1242*2208 iphone8 plus
        self.itemItemNextDiviView.frame=CGRectMake(self.itemItemNextDiviView.frame.origin.x, CGRectGetMaxY(self.itemTimeIconImageView.frame)+5,1,52+214+22+10);
    }
    
    
    self.temePeopleLabel.frame=CGRectMake(15, 10, CGRectGetWidth(self.itemView3.frame)-30, 21);
    self.temePeopleScrollView.frame=CGRectMake(35, CGRectGetMaxY(self.temePeopleLabel.frame)+8, CGRectGetWidth(self.itemView3.frame)-70, 57);
    self.noTemePeopleLabel.frame=CGRectMake(35, CGRectGetMaxY(self.temePeopleLabel.frame)+8, CGRectGetWidth(self.itemView3.frame)-70, 57);
    self.otherPeopleLabel.frame=CGRectMake(15, CGRectGetMaxY(self.temePeopleScrollView.frame)+10, CGRectGetWidth(self.itemView3.frame)-30, 21);
    self.otherPeopleScrollView.frame=CGRectMake(35, CGRectGetMaxY(self.otherPeopleLabel.frame)+10, CGRectGetWidth(self.itemView3.frame)-70, 57);
    self.noOtherPeopleLabel.frame=CGRectMake(35, CGRectGetMaxY(self.otherPeopleLabel.frame)+10, CGRectGetWidth(self.itemView3.frame)-70, 57);
    self.activityUpImageView.frame=CGRectMake(CGRectGetWidth(self.itemView3.frame)/2-11, CGRectGetHeight(self.itemView3.frame)-12, 22, 12);
    
    
    
    
    NSInteger scrollWidth =CGRectGetWidth(self.temePeopleScrollView.frame);
    NSInteger itemWidth = (scrollWidth-15*3)/3;
    //想与你组队的人
    if (model.teamUserList!=nil&&model.teamUserList.count>0) {
        //隐藏无数据
        self.noTemePeopleLabel.hidden=YES;
        for (NSInteger i=0; i<model.teamUserList.count; i++) {
            SINASINAStuHomeCoursItemModel2 *userModel = model.teamUserList[i];
            NSInteger x=i*(itemWidth+15)+7;
            UIView *teamView = [[UIView alloc]initWithFrame:CGRectMake(x, 0, itemWidth, itemWidth)];
            teamView.backgroundColor = [UIColor clearColor];
            UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, itemWidth, itemWidth)];
            [imageView sd_setImageWithURL:[NSURL URLWithString:userModel.userTitleImageUrl]];
            [teamView addSubview:imageView];
            [SINACircularBeadUtils makeCircularView:imageView];
            [self.temePeopleScrollView addSubview:teamView];
            
            [[SINAUiviewClickLiserner alloc]viewClickFunction:teamView andWithBlick:^(UIView *view) {
                SINAStudentHomeActivityItemPop *itemPot =[[SINAStudentHomeActivityItemPop alloc]initWithPageType:1];
                itemPot.coursItemModel=model;
                itemPot.model=userModel;
                
                [itemPot show];
            }];
        }
        self.temePeopleScrollView.contentSize=CGSizeMake((itemWidth+15)*model.teamUserList.count, itemWidth);
        self.temePeopleScrollView.frame=CGRectMake(35, CGRectGetMaxY(self.temePeopleLabel.frame)+8, CGRectGetWidth(self.itemView3.frame)-70, itemWidth);
        
        self.otherPeopleLabel.frame=CGRectMake(15, CGRectGetMaxY(self.temePeopleScrollView.frame)+10, CGRectGetWidth(self.itemView3.frame)-30, 21);
        
        
    }else{
        //显示无数据
        self.noTemePeopleLabel.hidden=NO;
    }
    //发起组队
    if (model.otherUserList!=nil&&model.otherUserList.count>0) {
        
        //隐藏无数据
        self.noOtherPeopleLabel.hidden=YES;
        
        for (NSInteger i=0; i<model.otherUserList.count; i++) {
            SINASINAStuHomeCoursItemModel2 *userModel = model.otherUserList[i];
            NSInteger x=i*(itemWidth+15)+7;
            UIView *teamView = [[UIView alloc]initWithFrame:CGRectMake(x, 0, itemWidth, itemWidth)];
            teamView.backgroundColor = [UIColor clearColor];
            UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, itemWidth, itemWidth)];
            [imageView sd_setImageWithURL:[NSURL URLWithString:userModel.userTitleImageUrl]];
            [teamView addSubview:imageView];
            [SINACircularBeadUtils makeCircularView:imageView];
            [self.otherPeopleScrollView addSubview:teamView];
            
            [[SINAUiviewClickLiserner alloc]viewClickFunction:teamView andWithBlick:^(UIView *view) {
                SINAStudentHomeActivityItemPop *itemPot =[[SINAStudentHomeActivityItemPop alloc]initWithPageType:0];
                itemPot.coursItemModel=model;
                itemPot.model=userModel;
                [itemPot show];
            }];
        }

        self.otherPeopleScrollView.frame=CGRectMake(35, CGRectGetMaxY(self.otherPeopleLabel.frame)+10, CGRectGetWidth(self.itemView3.frame)-70, itemWidth);
        self.otherPeopleScrollView.contentSize=CGSizeMake((itemWidth+15)*model.otherUserList.count, itemWidth);
    }else{
        //显示无数据
        self.noOtherPeopleLabel.hidden=NO;
    }
    
    self.itemView3.frame=CGRectMake(CGRectGetMaxX(self.itemTimeIconImageView.frame)+14, CGRectGetMaxY(self.itemView1.frame)+15, mainW-CGRectGetMaxX(self.itemTimeIconImageView.frame)-20-10, CGRectGetMaxY(self.otherPeopleScrollView.frame)+25);
    self.activityUpUiView.frame=CGRectMake(CGRectGetWidth(self.itemView3.frame)/2-30, CGRectGetHeight(self.itemView3.frame)-24, 60, 24);
    self.activityUpImageView.frame=CGRectMake(CGRectGetWidth(self.itemView3.frame)/2-11, CGRectGetHeight(self.itemView3.frame)-12, 22, 12);
    self.activityToLeftImageView.frame=CGRectMake(14, CGRectGetMaxY(self.otherPeopleScrollView.frame)-CGRectGetHeight(self.otherPeopleScrollView.frame)/2-7, 7, 13);
    self.activityToLeftUIView.frame=CGRectMake(0, CGRectGetMaxY(self.otherPeopleScrollView.frame)-CGRectGetHeight(self.otherPeopleScrollView.frame)/2-20, 30, 40);
    self.activityToRightImageView.frame=CGRectMake(CGRectGetWidth(self.itemView3.frame)-14-7, CGRectGetMaxY(self.otherPeopleScrollView.frame)-CGRectGetHeight(self.otherPeopleScrollView.frame)/2-7, 7, 13);
    self.activityToRightUIView.frame=CGRectMake(CGRectGetWidth(self.itemView3.frame)-30, CGRectGetMaxY(self.otherPeopleScrollView.frame)-CGRectGetHeight(self.otherPeopleScrollView.frame)/2-20, 30, 40);
    self.temePeopleScrollView.backgroundColor=[UIColor clearColor];
    self.otherPeopleScrollView.backgroundColor=[UIColor clearColor];
    
    __weak typeof(self) weakSelf = self;
    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityUpUiView andWithBlick:^(UIView *view) {
        if (weakSelf.itemCellBlock) {
            model.activityShowDetaile=NO;
            weakSelf.itemCellBlock(weakSelf.position, NO, model);
            [weakSelf showActivityDeatile:model];
        }
    }];
    //向左
    self.activityToLeftUIView.backgroundColor=[UIColor clearColor];
    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityToLeftUIView andWithBlick:^(UIView *view) {
        CGPoint offset =  weakSelf.otherPeopleScrollView.contentOffset;
        if (offset.x!=0) {
            CGPoint point = CGPointMake(offset.x-(itemWidth+15)*1, weakSelf.otherPeopleScrollView.contentOffset.y);
            if (point.x<=0) {
                point = CGPointMake(0, weakSelf.otherPeopleScrollView.contentOffset.y);
            }
            [weakSelf.otherPeopleScrollView setContentOffset:point animated:YES];
        }
    }];
    
    //向右
    self.activityToRightUIView.backgroundColor=[UIColor clearColor];
    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.activityToRightUIView andWithBlick:^(UIView *view) {
        CGPoint offset =  weakSelf.otherPeopleScrollView.contentOffset;
        if (offset.x<=weakSelf.otherPeopleScrollView.contentSize.width) {
            CGPoint point = CGPointMake(offset.x+(itemWidth+15)*1, weakSelf.otherPeopleScrollView.contentOffset.y);
            if (point.x>=weakSelf.otherPeopleScrollView.contentSize.width) {
                point = CGPointMake(weakSelf.otherPeopleScrollView.contentSize.width, weakSelf.otherPeopleScrollView.contentOffset.y);
            }
            [weakSelf.otherPeopleScrollView setContentOffset:point animated:YES];
        }
    }];
}

//点击完成
- (IBAction)activityFinishClick:(id)sender {
    //设置完成按钮点击事件
    NSInteger activityStartTime = [self.model.activityStartTime integerValue];
    NSInteger activityEndTime = [self.model.activityStopTime integerValue];
    //当前时间
    NSInteger currentTime = [[SINACalendarUtils currentTimeStr] integerValue];
    
    if (currentTime<activityStartTime) {
        DLog(@"活动未开始");
        [YPXToastView showToastViewWithText:@"活动未开始" andDuration:1 andParentView:self.itemView1];
    }else if(currentTime>=activityStartTime&&currentTime<=(activityEndTime)){
        //活动开始 以及结束后的半小时
        DLog(@"活动中");
        [YPXToastView showToastViewWithText:@"活动中" andDuration:1 andParentView:self.itemView1];
    }else if(currentTime>=activityEndTime&&currentTime<=(activityEndTime+30*60*1000)){
        //活动开始 以及结束后的半小时
        DLog(@"完成");
        if (self.finishItemBlock) {
            self.finishItemBlock(self.pos, 0, self.model);
        }
    }else{
        //超时
        [YPXToastView showToastViewWithText:@"活动已超时" andDuration:1 andParentView:self.itemView1];
        DLog(@"超时");
    }
    
}
//组队成功后 点击完成
- (IBAction)teamSuccessFinishActivity:(id)sender {
    //设置完成按钮点击事件
    NSInteger activityStartTime = [self.model.activityStartTime integerValue];
    NSInteger activityEndTime = [self.model.activityStopTime integerValue];
    //当前时间
    NSInteger currentTime = [[SINACalendarUtils currentTimeStr] integerValue];
    
    if (currentTime<activityStartTime) {
        DLog(@"活动未开始");
        [YPXToastView showToastViewWithText:@"活动未开始" andDuration:1 andParentView:self.itemView1];
    }else if(currentTime>=activityStartTime&&currentTime<=(activityEndTime)){
        //活动开始 以及结束后的半小时
        DLog(@"活动中");
        [YPXToastView showToastViewWithText:@"活动中" andDuration:1 andParentView:self.itemView1];
    }else if(currentTime>=activityEndTime&&currentTime<=(activityEndTime+30*60*1000)){
        //活动开始 以及结束后的半小时
        DLog(@"完成");
        if (self.finishItemBlock) {
            self.finishItemBlock(self.pos, 0, self.model);
        }
    }else{
        //超时
        [YPXToastView showToastViewWithText:@"活动已超时" andDuration:1 andParentView:self.itemView1];
        DLog(@"超时");
    }
}

@end
